﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using System.Data;
using System.Data.SqlClient;
using Maticsoft.DBUtility;

public partial class ReportF : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnViewReport_Click(object sender, EventArgs e)
    {
        try
        {
            string StartTime = tbStartTime.Text;
            string EndTime = tbEndTime.Text;

            if (string.IsNullOrEmpty(StartTime))
            {
                StartTime = "200001";
            }

            if (string.IsNullOrEmpty(EndTime))
            {
                EndTime = "209912";
            }

            this.ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
            LocalReport localReport = ReportViewer1.LocalReport;
            localReport.ReportPath = "Reports/Emp2/ReportF.rdlc";
            localReport.DataSources.Clear();

            // 按所属指挥中心分组
            DataSet ds1 = new DataSet();
            SqlParameter[] para1 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds1 = DbHelperSQL.ExecProc("uspEmp2ReportF1", para1);
            ReportDataSource rds1 = new ReportDataSource();
            rds1.Name = "DataSet1";
            rds1.Value = ds1.Tables[0];
            localReport.DataSources.Add(rds1);

            ////按城市分组
            //DataSet ds2 = new DataSet();
            //SqlParameter[] para2 = {new SqlParameter("@StartTime",StartTime)
            //                     ,new SqlParameter("@EndTime",EndTime)
            //                      };
            //ds2 = DbHelperSQL.ExecProc("uspEmp2ReportF2", para2);
            //ReportDataSource rds2 = new ReportDataSource();
            //rds2.Name = "DataSet2";
            //rds2.Value = ds2.Tables[0];
            //localReport.DataSources.Add(rds2);

            //按客户名称分组
            DataSet ds3 = new DataSet();
            SqlParameter[] para3 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds3 = DbHelperSQL.ExecProc("uspEmp2ReportF3", para3);
            ReportDataSource rds3 = new ReportDataSource();
            rds3.Name = "DataSet3";
            rds3.Value = ds3.Tables[0];
            localReport.DataSources.Add(rds3);

            //按课程类型分组
            DataSet ds4 = new DataSet();
            SqlParameter[] para4 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds4 = DbHelperSQL.ExecProc("uspEmp2ReportF4", para4);
            ReportDataSource rds4 = new ReportDataSource();
            rds4.Name = "DataSet4";
            rds4.Value = ds4.Tables[0];
            localReport.DataSources.Add(rds4);

            //按课程名称分组
            DataSet ds5 = new DataSet();
            SqlParameter[] para5 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds5 = DbHelperSQL.ExecProc("uspEmp2ReportF5", para5);
            ReportDataSource rds5 = new ReportDataSource();
            rds5.Name = "DataSet5";
            rds5.Value = ds5.Tables[0];
            localReport.DataSources.Add(rds5);

            ReportViewer1.LocalReport.Refresh();

        }
        catch (Exception ex)
        {

            throw;
        }
    }
}